package com.sdut.material.controller;


import com.sdut.material.service.IOutputService;
import com.sdut.material.util.JSONResult;
import com.sdut.material.util.LayUITableResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yu
 * @since 2022-04-20
 */
@Controller
@RequestMapping("/output")
public class OutputController {
    @Autowired
    private IOutputService outputService;
    @RequestMapping("/getOutputListPage")
    public String getOutputListPage() {
        return "output/output_list";
    }
    @RequestMapping("selectByPage")
    @ResponseBody
    public LayUITableResult selectByPage(Long page, Long limit) {
        return outputService.selectByPage(page,limit);
    }
    @RequestMapping("/outputRepository")
    @ResponseBody
    public JSONResult outputRepository(Integer outputId) {
        return outputService.outputRepository(outputId);
    }
    @RequestMapping("/cancelById")
    @ResponseBody
    public JSONResult cancelById(Integer outputId) {
        outputService.cancelById(outputId);
        return JSONResult.ok("取消成功");
    }
    @RequestMapping("/cancelAll")
    @ResponseBody
    public JSONResult cancelAll(String ids) {
        String[] idArray = ids.split(",");
        for (String outputId : idArray) {
            cancelById(Integer.parseInt(outputId));
        }
        return JSONResult.ok("取消成功");
    }
}

